﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <string>
using namespace std;

//1.()重载；
class MyPrint
{
public:
	void operator()()
	{
		cout << "hello world!" << endl;
	}
	void operator()(string text)
	{
		cout << text << endl;
	}
};
class MyAdd
{
public:
	int operator()(int v1, int v2)
	{
		return v1 + v2;
	}
};
void testFuncCall()
{
	MyPrint myPrint;
	//2.仿函数；
	myPrint();//hello world!
	myPrint("Function Call!");//Function Call!

	MyAdd myAdd;
	cout << myAdd(1, 1) << endl;//2
	//3.匿名对象；
	cout << MyAdd()(2, 2) << endl;//4
}

//main283：函数调用运算符重载
int main283()
{
	testFuncCall();

	system("pause");
	return EXIT_SUCCESS;
}